package com.fan.teamer.controller;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import org.apache.log4j.Logger;

import com.fan.teamer.model.domain.Member;
import com.fan.teamer.model.domain.Team;
import com.fan.teamer.service.MemberService;
import com.fan.teamer.service.TeamMemberService;
import com.fan.teamer.service.TeamService;

@ManagedBean(name = "myTeamBean")
@RequestScoped
public class MyTeamBean extends TeamerBean {

	private static Logger logger = Logger.getLogger(MyTeamBean.class);

	private Member member;
	private List<Team> myTeams;

	@ManagedProperty(value = "#{memberService}")
	private MemberService memberService;

	@ManagedProperty(value = "#{teamService}")
	private TeamService teamService;
	
	@ManagedProperty(value = "#{teamMemberService}")
	private TeamMemberService teamMemberService;

	public static Logger getLogger() {
		return logger;
	}

	public static void setLogger(Logger logger) {
		MyTeamBean.logger = logger;
	}

	public Member getMember() {
		member = memberService.getCurrentLoginMember();
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public List<Team> getMyTeams() {
		myTeams = teamMemberService.getMemberTeams(getMember());
		return myTeams;
	}

	public void setMyTeams(List<Team> myTeams) {
		
		this.myTeams = myTeams;
	}

	public MemberService getMemberService() {
		return memberService;
	}

	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}

	public TeamService getTeamService() {
		return teamService;
	}

	public void setTeamService(TeamService teamService) {
		this.teamService = teamService;
	}

	public TeamMemberService getTeamMemberService() {
		return teamMemberService;
	}

	public void setTeamMemberService(TeamMemberService teamMemberService) {
		this.teamMemberService = teamMemberService;
	}

	public String goToTeamPageAction() {

		return "team_page.faces";
	}
	
	public String goToUserProfilePageAction() {

		return "user_profile.faces";
	}
}
